package com.jz.community.moduleshoppingguide.home.presenter;

import com.jz.community.basecomm.mvp.BaseLifeCyclePresent;
import com.jz.community.basecomm.net.rxandroid.OnLoadListener;
import com.jz.community.moduleshoppingguide.home.bean.HotSaleAllBean;
import com.jz.community.moduleshoppingguide.home.bean.HotSaleShowBean;
import com.jz.community.moduleshoppingguide.home.model.ShoppingGuideModel;
import com.jz.community.moduleshoppingguide.home.model.ShoppingModelGuideImpl;
import com.jz.community.moduleshoppingguide.home.ui.BestSellersView;

/**
 * Created by Tony.Fan on 2018/3/13 10:42
 */
public class BestSellersPresenter extends BaseLifeCyclePresent<BestSellersView.View> implements BestSellersView.Presenter {

    private ShoppingGuideModel shoppingModel;
    private BestSellersView.View mView;

    public BestSellersPresenter(BestSellersView.View v) {
        mView = v;
        shoppingModel = new ShoppingModelGuideImpl(v.getContext());
    }

    @Override
    public void chunnelHotSaleAll(int page, int size, String showCategoryId, String platformId, int message, int type) {
        shoppingModel.chunnelHotSaleAll(page, size, showCategoryId, platformId, message, new OnLoadListener<HotSaleAllBean>() {
            @Override
            public void onSuccess(HotSaleAllBean hotSaleAllBean) {
                mView.getHotSaleAll(hotSaleAllBean, type);
            }

            @Override
            public void onFail(String msg, int code) {
                mView.onFail(msg);
            }
        });
    }

    @Override
    public void chunnelHotSaleShow(int message) {
        shoppingModel.chunnelHotSaleShow(message, new OnLoadListener<HotSaleShowBean>() {
            @Override
            public void onSuccess(HotSaleShowBean hotSaleShowBean) {
                mView.getHotSaleShow(hotSaleShowBean);
            }

            @Override
            public void onFail(String msg, int code) {
                mView.onFail(msg);
            }
        });
    }
}
